package 比屋作业.day14;
import java.util.Date;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
public class D14_4 {
    public static void main(String[] args) {
        userSysterm systerm=new userSysterm();
        systerm.resistMethod();
        systerm.logInMethod();
    }
}

class User{
    private String username;
    private String password;
    public User(String username,String password){
        this.password=password;
        this.username=username;
    }
    public String getUsername(){
        return username;
    }
    public String getPassword(){
        return password;
    }
    Date date=new Date();
}
class userSysterm {
    Date date=new Date();
    private List<User> users=new ArrayList<>();
    Scanner scanner=new Scanner(System.in);
    public void resistMethod(){
        System.out.println("请输入用户名：");
        String username=scanner.nextLine();
        System.out.println("请输入密码：");
        String password=scanner.nextLine();
        users.add(new User(username,password));
        System.out.println("注册成功！");
        System.out.println(date);
    }

    public void logInMethod(){
        System.out.println("请输入用户名：");
        String Username=scanner.nextLine();
        System.out.println("请输入密码：");
        String Password=scanner.nextLine();
        for (User user:users){
            if (user.getUsername().equals(Username)&&user.getPassword().equals(Password)){
                System.out.println("登陆成功！");
                System.out.println(date);
                return;
            }
        }
        System.out.println("登录失败！");
    }
}
